redis-script
Easily run redis scripts from Node.
Requirements
Install
npm install node-redis-script
Usage
const redis = require('redis').createClient();
const { createScript } = require('node-redis-script');
const incrbyExSrc = `
local current
current = redis.call('incrby',KEYS[1],ARGV[1])
redis.call('expire',KEYS[1],ARGV[2]);
return current
`;
const opts = { redis };
const incrbyEx = createScript(opts, incrbyExSrc);
const numKeys = 1;
const key = 'test';
const incr = 1;
const ex = 10;
const result = await incrbyEx(numKeys, key, incr, ex);
console.log(result);
Options
const opts = {
redis,
ioredis
};
Test
npm test